package com.ruoyi.functiontest.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.functiontest.mapper.TollMileageStatTestMapper;
import com.ruoyi.functiontest.domain.TollMileageStatTest;
import com.ruoyi.functiontest.service.ITollMileageStatTestService;

/**
 * 收费里程实测数据测试Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-09-24
 */
@Service
public class TollMileageStatTestServiceImpl implements ITollMileageStatTestService 
{
    @Autowired
    private TollMileageStatTestMapper tollMileageStatTestMapper;

    /**
     * 查询收费里程实测数据测试
     * 
     * @param id 收费里程实测数据测试主键
     * @return 收费里程实测数据测试
     */
    @Override
    public TollMileageStatTest selectTollMileageStatTestById(Long id)
    {
        return tollMileageStatTestMapper.selectTollMileageStatTestById(id);
    }

    /**
     * 查询收费里程实测数据测试列表
     * 
     * @param tollMileageStatTest 收费里程实测数据测试
     * @return 收费里程实测数据测试
     */
    @Override
    public List<TollMileageStatTest> selectTollMileageStatTestList(TollMileageStatTest tollMileageStatTest)
    {
        return tollMileageStatTestMapper.selectTollMileageStatTestList(tollMileageStatTest);
    }

    /**
     * 新增收费里程实测数据测试
     * 
     * @param tollMileageStatTest 收费里程实测数据测试
     * @return 结果
     */
    @Override
    public int insertTollMileageStatTest(TollMileageStatTest tollMileageStatTest)
    {
        return tollMileageStatTestMapper.insertTollMileageStatTest(tollMileageStatTest);
    }

    /**
     * 修改收费里程实测数据测试
     * 
     * @param tollMileageStatTest 收费里程实测数据测试
     * @return 结果
     */
    @Override
    public int updateTollMileageStatTest(TollMileageStatTest tollMileageStatTest)
    {
        return tollMileageStatTestMapper.updateTollMileageStatTest(tollMileageStatTest);
    }

    /**
     * 批量删除收费里程实测数据测试
     * 
     * @param ids 需要删除的收费里程实测数据测试主键
     * @return 结果
     */
    @Override
    public int deleteTollMileageStatTestByIds(Long[] ids)
    {
        return tollMileageStatTestMapper.deleteTollMileageStatTestByIds(ids);
    }

    /**
     * 删除收费里程实测数据测试信息
     * 
     * @param id 收费里程实测数据测试主键
     * @return 结果
     */
    @Override
    public int deleteTollMileageStatTestById(Long id)
    {
        return tollMileageStatTestMapper.deleteTollMileageStatTestById(id);
    }

    @Override
    public boolean hasChildById(Long id)
    {
        return tollMileageStatTestMapper.hasChildById(id) > 0;
    }

    /**
     * 批量更新实测单位审核状态（review1字段设置为0）
     * 
     * @return 更新的记录数
     */
    @Override
    public int updateReview1ToZero()
    {
        return tollMileageStatTestMapper.updateReview1ToZero();
    }

    /**
     * 校验所有数据的review1字段是否都为0
     * 
     * @return true 所有review1都为0，false 存在review1不为0的数据
     */
    @Override
    public boolean checkAllReview1IsZero()
    {
        int count = tollMileageStatTestMapper.countReview1NotZero();
        return count == 0;
    }

    /**
     * 根据条件批量更新业主审核状态（review2字段设置为0）
     * 
     * @param tollMileageStatTest 查询条件
     * @return 更新的记录数
     */
    @Override
    public int updateReview2ToZeroByCondition(TollMileageStatTest tollMileageStatTest)
    {
        return tollMileageStatTestMapper.updateReview2ToZeroByCondition(tollMileageStatTest);
    }

    /**
     * 校验所有数据的review1和review2字段是否都不为空且都为0
     * 
     * @return true 所有review1和review2都不为空且为0，false 存在不符合条件的数据
     */
    @Override
    public boolean checkAllReview1AndReview2AreZero()
    {
        int count = tollMileageStatTestMapper.countReview1OrReview2NotZero();
        return count == 0;
    }

    /**
     * 批量更新中心审核状态（review3字段设置为0）
     * 
     * @return 更新的记录数
     */
    @Override
    public int updateReview3ToZero()
    {
        return tollMileageStatTestMapper.updateReview3ToZero();
    }
}
